package BlockThread;

public class Method1 {
    //线程阻塞
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("hello!!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();

        System.out.println("join之前!!");
        //此处的join就是让当前的main线程来等待t线程执行结束 (等待t线程的run()执行完成)
        t.join();
        System.out.println("join之后!!");
    }
}
